<?php
class UserIdentity extends CUserIdentity {

    private $_id;
    
    public function authenticate() {
        $record = Member::model()->findByAttributes(array('username' => $this->username));
        if ($record === null)
            $this->errorCode = self::ERROR_USERNAME_INVALID;
        //else if ($record->password !== $this->password)
        else if($record->password!==(sha1(md5($this->password)))) 
            $this->errorCode = self::ERROR_PASSWORD_INVALID;
        else if($record->active == 0){
            $this->errorCode = self::ERROR_PASSWORD_INVALID;
        }  else {
            
            $this->_id=$record->member_id;
            $this->username = $record->username; 
            $this->errorCode = self::ERROR_NONE;
        }
        return !$this->errorCode;
    }
    public function getId() {
        return $this->_id;
    }
}